<template>
  <div class="iframe-container">
    <iframe
      :src="URL"
      frameborder="0"
      width="100%"
      height="100%"
      v-if="openType == 'inner'"
    ></iframe>

    <div class="iframe-body"></div>
  </div>
</template>

<script>
export default {
  name: "Iframe",
  data() {
    return {
      URL: "",
      openType: "inner",
    };
  },
  watch: {
    $route: {
      handler(val) {
        let {
          query: { openType, url },
        } = val;
        this.openType = openType;
        this.URL = decodeURIComponent(url);
        if (openType == "blank") {
          window.open(this.URL);
        }
      },
      immediate: true,
    },
  },
  mounted() {},
};
</script>

<style lang="less" scoped>
.iframe-container {
  width: 100%;
  height: 100%;
  .iframe-body {
    width: 100%;
    height: 100%;
  }
}
</style>
